<template>
  <div id="app">
    <el-input class="input" v-model="msg" placeholder="Carousel字幕"></el-input>
    <div class="viewList">
      <div class="viewItem" v-for="(item, index) in listData" :key="index">
        <ScrollText :msg="msg" :style="scrollStyle[index]"></ScrollText>
      </div>
    </div>
  </div>
</template>

<script>
import ScrollText from "./components/ScrollText";
export default {
  components: { ScrollText },
  data() {
    return {
      msg: "欢迎各位领导莅临指导！",
      listData: [...new Array(12)]
    };
  },
  computed: {
    scrollStyle() {
      return this.listData.map((item, index) => {
        const columnIndex = Math.floor(index / 4);
        const rowIndex = index % 4;
        console.log('1=',index,columnIndex,rowIndex);
        
        return {
          transform: `translate(-${rowIndex * 210}px,-${columnIndex * 120}px)`
        };
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.input {
  width: 800px;
  margin: 10px auto;
}
.viewList {
  display: flex;
  flex-flow: row;
  flex-wrap: wrap;
  width: 840px;
  height: 360px;
  margin: 0 auto;
  justify-content: space-around;
  align-content: space-around;
  .viewItem {
    box-sizing: border-box;
    border: 1px solid #DCDFE6;
    width: 210px;
    height: 120px;
    overflow: hidden;
  }
}
</style>
